package index;

import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;

import entities.concept.Concept;
import entities.ConceptAssertion;
import entities.Individual;

public class IndexTreeNode {
	private ConceptAssertion ca;
	protected Individual ind;
	protected Concept data;
	protected int balance;
	protected ArrayList<IndexTreeNode> link;

	
	public IndexTreeNode(ConceptAssertion ca){
		this.ca = ca;
		this.data = ca.getConcept();
		this.ind = ca.getIndividual();
		balance = 2;
		link = new ArrayList<IndexTreeNode> (2);
		link.add(null);
		link.add(null);
	}
	
//	public IndexTreeNode(Concept data) {
//		this.data = data;
//		balance = 2;
//		link = new ArrayList<IndexTreeNode> (2);
//		link.add(null);
//		link.add(null);
//	}

	public ConceptAssertion getNodeAssertion(){
		return this.ca;
	}
	public Concept getData() {
		return data;
	}
	
	public Individual getID(){
		return ind;
	}

//	public void setData(Concept data) {
//		this.data = data;
//	}

	public IndexTreeNode getLeft() {
		return link.get(0);
	}
	
	public IndexTreeNode getRight() {
		return link.get(1);
	}

	public void print(OutputStream s, String prefix, String newline) {
		PrintStream out = new PrintStream(s);
		out.print(prefix + data + newline);
		if (prefix.equals("")) {
			prefix = "  ";
		}
		else {
			prefix += prefix;
		}
		if (link.get(0) != null) {
			out.print("L");
			link.get(0).print(out, prefix, newline);
		}
		if (link.get(1) != null) {
			out.print("R");
			link.get(1).print(out, prefix, newline);
		}
	}
}
